package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.gdms.model.Student;
import com.zr.gdms.service.StudentService;
import com.zr.gdms.serviceimpl.StudentServiceImpl;

/**
 * @author  shichongming
 * @E-mail: 
 * @date 创建时间：2017年5月31日 下午5:27:18 
 * @version 1.0 
 * @parameter  
 * @since  
 * @return  
 */

public class UpdateSelectCourseControllerSCM extends HttpServlet{

	  StudentService stu=new StudentServiceImpl();
	  @Override
	public void init() throws ServletException {
		
		super.init();
	}
	//修改已经选择的课题
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		HttpSession session = req.getSession();		
		Student st=(Student)session.getAttribute("student");		
		int sid=st.getSid();
		int cid=stu.sfindCidBySid(sid);
		boolean flag=stu.supdateOldCstate(cid);		
		PrintWriter pw=resp.getWriter();
		if(flag){
			boolean flag1=stu.sdeleteScoreBysid(sid);
			if(flag1){
				pw.write("1");
			}else{
				pw.write("0");
			}
		}else{
			pw.write("0");
		}
		
		
		
		
		
		
	}
}
